<template>
  <div style=";height: 100%;">
    <div class="blueHeader">
      <div style="display: flex;margin-top: 46px;margin-left: 40px;">
        <span class="leftText">{{ taskForm.name }}</span>
        <div class="leftYellow">{{ taskForm.status }}</div>
      </div>
      <div style="display: flex;margin-top: 46px;color:#FFFFFF;margin-right: 40px;">
        <div class="topRight">任务编号：{{ taskForm.no }}</div>
        <div class="topRight">开始时间：{{ taskForm.releaseTime }}</div>
        <div class="topRight">承办部门：{{ taskForm.undertakeDeptName }}</div>
      </div>
    </div>
    <div style="background-color: #ffffff;width: 92%;margin: auto;margin-top: -143px;border-radius: 4px;">
      <el-tabs class="topTab" v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="基本信息" name="1" style="">
          <BaseInfo :taskInfo="taskForm" />
        </el-tab-pane>
        <el-tab-pane label="生产计划" name="2" v-if="taskForm.taskTypeName">
          <ProductionPlan :taskTypeName="taskForm.taskTypeName" />
        </el-tab-pane>
        <el-tab-pane label="进度管理" name="3">
          <TechnicalDesignDocument />
        </el-tab-pane>
        <el-tab-pane label="技术管理" name="4">
          <TechnicalSummary />
        </el-tab-pane>
        <el-tab-pane label="质检管理" name="5">
          <PreAcceptanceApplication />
        </el-tab-pane>
        <el-tab-pane label="成果归档" name="6">
          <OutcomeDocument />
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<script>
import BaseInfo from './baseInfo.vue'
import ProductionPlan from './productionPlan.vue'
import TechnicalDesignDocument from './technicalDesignDocument.vue'
import TaskProgressReport from './taskProgressReport.vue'
import TaskExtensionRequest from './taskExtensionRequest.vue'
import TechnicalSummary from './technicalSummary.vue'
import OutcomeDocument from './outcomeDocument.vue'
import QualityInspectionApplication from './qualityInspectionApplication.vue'
import PreAcceptanceApplication from './preAcceptanceApplication.vue'
import { getTask } from '@/api/project/task'
export default {
  components: {
    BaseInfo,
    ProductionPlan,
    TechnicalDesignDocument,
    TaskProgressReport,
    TaskExtensionRequest,
    TechnicalSummary,
    OutcomeDocument,
    QualityInspectionApplication,
    PreAcceptanceApplication
  },
  data() {
    return {
      activeName: '2',
      taskForm: {}
    };
  },
  async created() {
    const data = await getTask(this.$route.query.taskId)
    this.taskForm = data.data
    this.taskForm.nature = this.convertDict(this.taskForm.nature, 'xmgl_task_nature');
    this.taskForm.taskTypeName = this.convertDict(this.taskForm.taskType, 'xmgl_task_type');
    this.taskForm.taskUnitName = this.convertDict(this.taskForm.taskUnit, 'xmgl_task_unit');
    this.taskForm.status = this.convertDict(this.taskForm.status, 'xmgl_status');
    this.taskForm.id = this.$route.query.taskId
  },
  mounted() {

  },
  methods: {
    handleClick(tab, event) {
      console.log(tab, event);
    },
    convertDict(dictValue, dictName) {
      const labelMap = {};
      let dict = this.$store.state.dictNew[dictName]
      dict.forEach(item => {
        labelMap[item.value] = item.label
      });
      let label = ''
      if (labelMap.hasOwnProperty(dictValue)) {
        label = labelMap[dictValue];
      }
      return label
    }
  }
};
</script>

<style scoped lang="scss">
.blueHeader {
  height: 225px;
  width: 98%;
  background-color: #47ACF4;
  margin: auto;
  border-radius: 2px;
  display: flex;
  justify-content: space-between;

  .leftText {
    font-family: PingFangSC-Medium;
    font-weight: 500;
    font-size: 18px;
    color: #FFFFFF;
    line-height: 24px;
  }

  .leftYellow {
    background: #E6A23C;
    border-radius: 100px;
    color: #FFFFFF;
    width: 63.56px;
    height: 26px;
    margin-left: 15px;
    text-align: center;
    line-height: 25px;
  }
}

::v-deep .el-tabs__nav-scroll {
  padding-left: 20px;
}

.topTab {
  margin-top: 30px;
}

.topRight {
  height: 24px;
  font-family: PingFangSC-Regular;
  font-weight: 400;
  font-size: 14px;
  line-height: 24px;
  margin-left: 20px;
}
</style>

<style>
.el-tabs__item {
  font-family: PingFangSC-Regular;
  font-weight: 400;
  font-size: 14px;
  color: #909399;
  text-align: center;
  line-height: 50px;
  height: 50px
}

.el-tabs__item.is-active {
  color: #47ACF4;
  font-weight: bold;
}
</style>
